#include<bits/stdc++.h>
using namespace std;

int T;
int n,m,l,v;
struct car_object{
    int d,v,a;
};
struct dw{
    double l,r;
};

bool cmp(dw a,dw b){
    return a.l>b.l;
}

int work(vector<dw> po,int pos[]){
    int cnt=0;
    for(int i=0;i<po.size()-1;i++){
        for(int j=0;j<po.size()-i-1;j++){
            if(po[j].l>po[j+1].l){
                dw ls=po[j+1];
                po[j+1]=po[j];
                po[j]=ls;
            }
        }
    }
    bool jl=0;
    for(int i=po.size()-1;i>=0;i--){
        if(i==0){
            if(jl==0)cnt+=1;
            return cnt;
        }
        if(po[i-1].r>=po[i].l){
            for(int j=0;j<m;j++){
                if(pos[j]>=po[i].l&&pos[j]<=po[i-1].r){
                    cnt+=1;
                    jl=1;
                    break;
                }
            }

        }
        if(po[i-1].r<po[i].l&&jl==1){
            jl==0;
        }
        if(po[i-1].r<po[i].l&&jl==0){
            cnt+=1;
        }
    }
    return cnt;
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(int I=0;I<T;I++){
        cin>>n>>m>>l>>v;
        car_object car[n];
        int position[m];
        for(int i=0;i<n;i++){
            cin>>car[i].d>>car[i].v>>car[i].a;
        }
        for(int i=0;i<m;i++){
            cin>>position[i];
        }
        sort(position,position+m);
        //speed_over
        vector<int> ocp;//speed over car's position 
        for(int i=0;i<n;i++){
            int p=0;
            for(int ii=0;ii<m;ii++){
                if(position[ii]>=car[i].d){
                    p=ii;break;
                }
            }
            if(car[i].a<0&&sqrt(car[i].v*car[i].v+2*car[i].a*(position[p]-car[i].d))>v){
                ocp.push_back(i);
            }
            if(car[i].a>0&&sqrt(car[i].v*car[i].v+2*car[i].a*(position[m-1]-car[i].d))>v){
                ocp.push_back(i);
            }          
            if(car[i].a==0&&car[i].v>v){
                ocp.push_back(i);
            }
        }
        cout<<ocp.size()<<" ";
        //delete 
        int nnum=ocp.size(),keep=0;
        bool rec=0;
        vector<dw> po; 
        for(int i=0;i<nnum;i++){
            car_object ncar=car[ocp[i]];
            if(ncar.a==0||ncar.a>0){
                if(rec==0){
                    rec=1;
                    keep+=1;
                    po.push_back({double(position[m-1]),double(position[m-1])});
                }
                continue;
            }
            if(ncar.a<0){
                double s=(-1)*(v/ncar.a)+ncar.d;
                //cout<<ncar.d<<" "<<s;   
                po.push_back({double(ncar.d),s});
            }

        }
        keep+=work(po,position);
        cout<<m-keep<<endl;
    }

    return 0;
}


/*
1
10 10 150307 247
62978 968 -5
51700 883 -3
40408 564 -1
60366 870 -41
35943 797 -7
47476 595 -11
59020 672 -10
81024 964 -11
80637 695 -5
66114 874 -1
46720 48066 57373 60882 68842 72773 82820 116695 122159 150307
*/

